//IP自定义校验规则
export const ipRuleValidator = async (_rule, value) => {
  //ip正则表达式
  const ipRule =
    /^(1[0-9]{2}|2[0-4][0-9]|25[0-5]|(\d){1,2})\.(1[0-9]{2}|2[0-4][0-9]|25[0-5]|(\d){1,2}|0)\.(1[0-9]{2}|2[0-4][0-9]|25[0-5]|(\d){1,2}|0)\.(1[0-9]{2}|2[0-4][0-9]|25[0-5]|(\d){1,2}|0)$/g
  const flag = ipRule.test(value)
  if (value === '') {
    return Promise.reject('请填写ip地址!')
  } else if (!flag) {
    return Promise.reject('ip地址匹配错误!')
  } else {
    return Promise.resolve()
  }
}